package com.itheima.day03;
/*
案例4:for..if嵌套使用:
        水仙花数
        (三位数,各个位的立方和等于原数值.)
 */

public class TestClassCase04 {
    public static void main(String[] args) {

        int a=0;
        System.out.println("100--1000以内的水仙花数:");
        for (int i = 100; i < 1000; i++) {

            int g=i%10;
            int s=i/10%10;
            int b=i/100%10;



            if (g*g*g+s*s*s+b*b*b  == i) {
                System.out.print(i+" ");
                a++;
                if (a%2==0){
                    System.out.println();

                }

            }
        }

        System.out.println("水仙花总个数:" + a);
    }
}
